<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
  </a-card>
</template>

<script>

import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  name: 'MesMaterialSetProductList',
  mixins: [JeecgListMixin],
  components: {},
  props: {
    mainId: {
      type: String,
      default: '',
      required: false
    }
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        if (!this.mainId) {
          this.clearList()
        } else {
          this.queryParam['unitsn'] = val
          this.loadData(1)
        }
      }
    }
  },
  data() {
    return {
      description: '原料批次明细列表',
      disableMixinCreated: true,
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '产线或产线组',
          align: 'center',
          dataIndex: 'line'
        },
        {
          title: '工位',
          align: 'center',
          dataIndex: 'op'
        },
        {
          title: '工件号',
          align: 'center',
          dataIndex: 'unitsn'
        },
        {
          title: '物料批次号',
          align: 'center',
          dataIndex: 'lot'
        },
        {
          title: '物料编号',
          align: 'center',
          dataIndex: 'itempartno'
        },
        {
          title: '耗材描述',
          align: 'center',
          dataIndex: 'itemDes'
        },
        {
          title: '用料数量',
          align: 'center',
          dataIndex: 'qty'
        },
        {
          title: '用料时间',
          align: 'center',
          dataIndex: 'ctime'
        }

      ],
      url: {
        list: '/trace/barcodeTrace/mesMaterialSetByProduct'
      },
      dictOptions: {}
    }
  },
  created() {
  },
  computed: {
    importExcelUrl() {
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`
    }
  },
  methods: {
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    }

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>
